﻿// PRngListDlg.cpp: 实现文件
//

#include "pch.h"
#include "JointSerialTest.h"
#include "PRngListDlg.h"
#include "afxdialogex.h"
#include "Devices.h"


// PRngListDlg 对话框

IMPLEMENT_DYNAMIC(PRngListDlg, CDialogEx)

PRngListDlg::PRngListDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_PREPLIST, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

PRngListDlg::~PRngListDlg()
{
}

void PRngListDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_PLIST, datalist);
}

BOOL PRngListDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	SetIcon(m_hIcon, TRUE);			// 设置大图标

	for (size_t k = 0; k < 9; k++)
	{
		datalist.InsertColumn(k, titles[k], LVCFMT_CENTER, width[k]);
	}
	return 0;
}

LRESULT PRngListDlg::addData(WPARAM wParam, LPARAM lParam)
{
	RANGETABLE* rngtab = (RANGETABLE*)wParam;
	ARANGEDATA* rngdata;
	CString nextContent;
	
	datalist.DeleteAllItems();
	for (INT nextRowNUm = 0; nextRowNUm < rngtab->ph.len; nextRowNUm++)
	{
		INT idx = 0;
		rngdata = &(rngtab->ranges[nextRowNUm]);
		nextRowNUm = datalist.InsertItem(nextRowNUm, _T(""));
		nextContent.Format(_T("%d"), rngdata->PRN);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%d"), rngdata->glof);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%lf"), rngdata->psr);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), rngdata->psrstd);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%lf"), rngdata->adr);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), rngdata->adrstd);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), rngdata->Dopp);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), rngdata->CNO);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), rngdata->Locktime);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
	}
	return LRESULT();
}


BEGIN_MESSAGE_MAP(PRngListDlg, CDialogEx)
	ON_MESSAGE(LISTMSG_GETPRNG, addData)
END_MESSAGE_MAP()


// PRngListDlg 消息处理程序
